﻿@model IPager
@{var buttonCnt=10;}
<ul class="ui-widget-pager">
    <li><p>当前第@(Model.PageIndex)页/共@(Model.PageCount)页，每页显示@(Model.Count)/@(Model.PageSize)条数据/共@(Model.TotalCount)条数据</p></li>
    @if(Model.PageIndex>1){
    <li>
        @Ajax.ActionLink("首页", null, Model.Go(0), new AjaxOptions { UpdateTargetId = "Main" })
    </li>
    }
    @{
        var cur = Model.PageIndex+buttonCnt/2;
        if (cur > Model.PageCount) { cur = Model.PageCount; }
        cur-=buttonCnt-1;
        if (cur < 1) { cur = 1; }
        for (var idx = 0; cur <= Model.PageCount && idx < buttonCnt; idx++, cur++) 
        {
            <li>
                @if (Model.PageIndex == cur)
                {
                    <span class="cur">@cur</span>
                }
                else
                {
                @Ajax.ActionLink(cur + "", null, Model.Go(cur), new AjaxOptions { UpdateTargetId = "Main" })
                }
            </li>
        }
    }
    @if(Model.PageIndex<Model.PageCount)
    {
    <li>
        @Ajax.ActionLink("最后一页", null, Model.Go(Model.PageCount), new AjaxOptions { UpdateTargetId = "Main" })
    </li>
    }
    @if (Model.PageCount > buttonCnt)
    {
     <li class="search">
         @using(Ajax.BeginForm(null,Model.Go(-1),new AjaxOptions{ UpdateTargetId = "Main" }))
         {
            @Html.EditorFor(p => p.PageIndex)<input type="submit" value="转到" />
         }
     </li>   
	}
</ul>